package data_structures_and_algorithms.bit_arithmetic.learn;

/**
 * @ClassName Example001
 * @Description: 课堂例子
 * @Author: yongliang.ma
 * @Create_time:2022/10/23 18:32
 */
public class Example001 {
    public static void main(String[] args) {
        printTwoNumber(Integer.MAX_VALUE);
        printTwoNumber(Integer.MIN_VALUE);
        printTwoNumber(10);
        printTwoNumber(-10);
    }

    // 打印一个数字的二进制上的数字
    public static void printTwoNumber(int num){
        for (int i = 31; i >= 0; i--) {
            System.out.print((num & (1 << i)) == 0? "0":"1");
        }
        System.out.println();
    }
}
